<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Pc_Api_V2_Ship extends Controller_Pc_Api_v2_Base
{
    // 数据请求结果
    private $result;
    /**
     * 参数验证对象
     * @var Request_Api_V2_Ship
     */
    private $validation;

    /**
     * 签证服务
     * @var Service_Api_Ship
     */
    private $service;

    public function before()
    {
        parent::before();
        $this->result = array(
            'status' => true,
            'msg' => '操作成功',
            'data' => array()
        );
        $this->validation = Request_Api_V2_Factory::create('ship', $this->request_params);
        $this->service = new Service_Api_Ship();
    }
    public function after()
    {
        $this->send_datagrams($this->client_info['id'], $this->result, $this->client_info['secret_key']);
    }

    /**新版接口**/
    /**
     * 航次列表
     * User: netman
     * Date: 2023/10/18 15:17
     */
    public function action_ship_line_list()
    {
        try {
            $this->validation->ship_line_list()->check();
            $data = $this->service->ship_line_list($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }
    /**
     * 航线详情
     * Author gl
     * 2022/9/2
     */
    public function action_ship_line_info()
    {
        try {
            $this->validation->ship_line_info()->check();
            $data = $this->service->info($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }

    }

    /**
     * 根据航线和日期查询套餐
     * User: netman
     * Date: 2023/10/18 15:04
     */
    public function action_date_suit()
    {
        try {
            $this->validation->date_suit()->check();
            $data = $this->service->date_suit($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }

    }

    /**
     * 获取航线的航期
     * User: netman
     * Date: 2023/10/18 15:10
     */
    public function action_ship_line_voyage()
    {
        try {
            $this->validation->ship_line_voyage()->check();
            $data = $this->service->ship_line_voyage($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }

    }
    /**
     * 获取邮轮航线
     * Author gl
     * 2022/9/2
     */
    public function action_ship_line()
    {
        try {
            $this->validation->ship_line()->check();
            $data = $this->service->ship_line($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }
    /**
     * 附加产品列表
     * Author gl
     * 2022/9/16
     */
    public function action_ship_line_additional()
    {
        try {
            $this->validation->ship_line_additional()->check();
            $data = $this->service->ship_line_additional($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }
    /**
     * 预定下单
     * @throws Kohana_Exception
     * Author gl
     * 2022/9/5
     */
    public function action_create_order()
    {
        try {
            $this->validation->create_order()->check();

            $this->request_params['member_info'] = $this->member_info;
            $data = $this->service->create_order($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }

    }
    /**
     * 航线切换列表
     * Author gl
     * 2022/9/6
     */
    public function action_all_ship_line()
    {
        try {
            $this->validation->all_ship_line()->check();
            $data = $this->service->all_ship_line($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }
    /**邮轮公司相关**/
    /**
     * 邮轮介绍
     * Author gl
     * 2022/9/13
     */
    public function action_ship_info()
    {
        try {
            $this->validation->ship_info()->check();
            $data = $this->service->ship_info($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    /**
     * 热门产品
     * Author gl
     * 2022/9/13
     */
    public function action_company_hot_product()
    {
        try {
            $this->validation->company_hot_product()->check();
            $data = $this->service->company_hot_product($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }

    }

    /**
     * 订单合同
     * @date 2022/9/29 0029
     * @author gl
     */
    public function action_order_contract()
    {
        try {
            $this->validation->order_contract()->check();
            $data = $this->service->order_contract($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }

    }
    /**** 新版升级接口 ****/
    /** 栏目首页板块 **/
    /**
     * 栏目首页搜索框下推荐航线
     */
    public function action_index_search_hot_line()
    {
        try {
            $this->validation->index_search_hot_line()->check();
            $data = $this->service->index_search_hot_line($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    /**
     * 栏目首页搜索框下邮轮系列
     */
    public function action_index_search_company_list()
    {
        try {
            $this->validation->index_search_company_list()->check();
            $data = $this->service->index_search_company_list($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    /**
     * 栏目首页爆款推荐航线
     */
    public function action_index_common_list()
    {
        try {
            $this->validation->index_common_list()->check();
            $data = $this->service->index_common_list($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    /**
     * 栏目首页特价推荐航线
     */
    public function action_index_special_list()
    {
        try {
            $this->validation->index_special_list()->check();
            $data = $this->service->index_special_list($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    /**
     * 邮轮品牌列表
     */
    public function action_company_list()
    {
        try {
            $this->validation->company_list()->check();
            $data = $this->service->company_list($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    /**
     * 栏目首页评论列表
     */
    public function action_index_comment_list()
    {
        try {
            $data = $this->service->index_comment_list($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    /** 栏目航线列表板块 **/

    /**
     * 航线列表筛选条件
     */
    public function action_query_condition()
    {
        try {
            $data = $this->service->query_condition();
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    /**
     * 邮轮公司条件列表
     */
    public function action_query_supplier_list()
    {
        try {
            $data = $this->service->query_supplier_list();
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    /**
     * 获取所有目的地列表
     */
    public function action_dest_list()
    {
        try {
            $data = $this->service->dest_list();
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    /**
     * 航线列表
     */
    public function action_line_list()
    {
        try {
            $data = $this->service->line_list($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    /**
     * 航期列表
     */
    public function action_date_list()
    {

        try {
            $this->validation->date_list()->check();
            $data = $this->service->date_list($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    public function action_start_dest_list()
    {
        try {
            $data = $this->service->start_dest_list();
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    public function action_company_info()
    {
        try {
            $this->validation->company_info()->check();
            $data = $this->service->company_info($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }
}